﻿using PCBase.UIControls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionCore
{
    public class PRM_Get_Rec
    {
        private double _upDistance = 0;
        [DisplayName("扭转Z预上升高度"), Description("扭转前Z上升高度，设定范围：0-0.3，单位：mm")]
        public double UpDistance
        {
            get
            {
                return _upDistance;
            }
            set
            {
                _upDistance = value;
                if (_upDistance < 0)
                {
                    _upDistance = 0;
                }

                if (_upDistance > 0.3)
                {
                    _upDistance = 0.3;
                }
            }
        }


        [DisplayName("扭转角度"), Description("扭转角度，设定范围：0-90，单位：°")]
        [TypeConverter(typeof(PropertiesExpandConverter))]
        public PRM_Get_Rec_RotationDeg LDTRGet_RotationDeg { get; set; } = new PRM_Get_Rec_RotationDeg();



        private double _rotationSpeed = 5;
        [DisplayName("扭转速度"), Description("扭转 R轴运转速度(°/s)")]
        public double RotationSpeed
        {
            get { return _rotationSpeed; }
            set
            {
                _rotationSpeed = value;
                if (_rotationSpeed > 480)
                {
                    _rotationSpeed = 480;
                }
                if (_rotationSpeed < 1)
                {
                    _rotationSpeed = 1;
                }
            }
        }


        [DisplayName("扭转次数"), Description("扭转次数，设定范围：0-5，单位：次")]
        [TypeConverter(typeof(PropertiesExpandConverter))]
        public PRM_Get_Rec_RotationCount LDTRGet_RotationCount { get; set; } = new PRM_Get_Rec_RotationCount();

        public override string ToString()
        {
            return "...";
        }
    }

    public class PRM_Get_Rec_RotationDeg
    {
        private double _ldtr1RotationDeg = 0;
        [DisplayName("TR1"), Description("扭转角度，设定范围：0-90，单位：°")]
        public double LDTR1RotationDeg
        {
            get
            {
                return _ldtr1RotationDeg;
            }
            set
            {
                _ldtr1RotationDeg = value;
                if (_ldtr1RotationDeg < 0)
                {
                    _ldtr1RotationDeg = 0;
                }

                if (_ldtr1RotationDeg > 90)
                {
                    _ldtr1RotationDeg = 90;
                }
            }
        }

        private double _ldtr2RotationDeg = 0;
        [DisplayName("TR2"), Description("扭转角度，设定范围：0-90，单位：°")]
        public double LDTR2RotationDeg
        {
            get
            {
                return _ldtr2RotationDeg;
            }
            set
            {
                _ldtr2RotationDeg = value;
                if (_ldtr2RotationDeg < 0)
                {
                    _ldtr2RotationDeg = 0;
                }

                if (_ldtr2RotationDeg > 90)
                {
                    _ldtr2RotationDeg = 90;
                }
            }
        }

        public override string ToString()
        {
            return "...";
        }

    }

    public class PRM_Get_Rec_RotationCount
    {
        private int _ldtr1rotationCount = 0;

        [DisplayName("TR1"), Description("扭转次数，设定范围：0-5，单位：次")]
        public int LDTR1RotationCount
        {
            get
            {
                return _ldtr1rotationCount;
            }
            set
            {
                _ldtr1rotationCount = value;
                if (_ldtr1rotationCount < 0)
                {
                    _ldtr1rotationCount = 0;
                }

                if (_ldtr1rotationCount > 5)
                {
                    _ldtr1rotationCount = 5;
                }
            }
        }

        private int _ldtr2rotationCount = 0;

        [DisplayName("TR2"), Description("扭转次数，设定范围：0-5，单位：次")]
        public int LDTR2RotationCount
        {
            get
            {
                return _ldtr2rotationCount;
            }
            set
            {
                _ldtr2rotationCount = value;
                if (_ldtr2rotationCount < 0)
                {
                    _ldtr2rotationCount = 0;
                }

                if (_ldtr2rotationCount > 5)
                {
                    _ldtr2rotationCount = 5;
                }
            }
        }

        public override string ToString()
        {
            return "...";
        }

    }
    public class PRM_ClampPar_Rec
    {
        [DisplayName("夹持点"), Browsable(true), ReadOnly(true)]
        [TypeConverter(typeof(PropertiesExpandConverter))]
        public Clamp_Par Close { get; set; } = new Clamp_Par();

        [DisplayName("张开点"), Browsable(true), ReadOnly(true)]
        [TypeConverter(typeof(PropertiesExpandConverter))]
        public Clamp_Par Open { get; set; } = new Clamp_Par();

        private  static  short TR1pushingForce = 40;
        private  static  short TR2pushingForce = 40;
        public override string ToString()
        {
            return "...";
        }

        public class Clamp_Par
        {
            private short _speed = 5;
           [DisplayName("定位运行速度"), Description("定位模式运行速度，设定范围：5-80，单位：mm/s")]
            public short Speed
            {
                get
                {
                    return _speed;
                }
                set
                {
                    _speed = value;
                    if (_speed < 5)
                    {
                        _speed = 5;
                    }

                    if (_speed > 80)
                    {
                        _speed = 80;
                    }
                }
            }



            [DisplayName("目标位置"), Description("运行目标位置，设定范围：-4~0.1，单位：mm")]
            [TypeConverter(typeof(PropertiesExpandConverter))]

            public Clamp_ParTarPos TarPosExt { get; set; } = new Clamp_ParTarPos();




            [DisplayName("夹持推力"), Description("当夹持推力设定值不等于0，为推力运行; 若设定推力需大于等于推力阀值，设定范围：0-200,单位：%")]
            [TypeConverter(typeof(PropertiesExpandConverter))]
            public Clamp_PushingForce PushingForceExt { get; set; } = new Clamp_PushingForce();



            [DisplayName("推力阀值"), Description("推力阀值设定小于夹持推力，设定范围：0-200，单位：%")]
            [TypeConverter(typeof(PropertiesExpandConverter))]
            public Clamp_PushingForceTriggerLV TriggerLVExt { get; set; } = new Clamp_PushingForceTriggerLV();



            private short _pushingSpeed =1;

            [DisplayName("推力运行速度"), Description("推力运行速度，设定范围：5-50 单位：mm/s")]
            public short PushingSpeed
            {
                get
                {
                    return _pushingSpeed;
                }
                set
                {
                    _pushingSpeed = value;
                    if (_pushingSpeed < 5)
                    {
                        _pushingSpeed = 5;
                    }

                    if (_pushingSpeed > 50)
                    {
                        _pushingSpeed = 50;
                    }
                }
            }

            private short _movingForce=100;
            [DisplayName("位置运行推动力"), Description("定位运行推力，设定范围：1-200 单位：%")]
            public short MovingForce
            {
                get
                {
                    return _movingForce;
                }
                set
                {
                    _movingForce = value;
                    if (_movingForce < 0)
                    {
                        _movingForce = 1;
                    }

                    if (_movingForce > 200)
                    {
                        _movingForce = 200;
                    }
                }
            }


            [DisplayName("推力运行距离"), Description("推力范围+-，设定范围：0.1-4.0 单位:mm")]
            [TypeConverter(typeof(PropertiesExpandConverter))]
            public Clamp_PushingForceInPos InPosExt { get; set; } = new Clamp_PushingForceInPos();



            public override string ToString()
            {
                return "...";
            }
        }
        public class Clamp_ParTarPos
        {
            private double _tr1tarPos = -2;

            [DisplayName("TR1"), Description("运行目标位置，设定范围：-4~0.1，单位：mm")]
            public double TR1TarPos
            {
                get
                {
                    return _tr1tarPos;
                }
                set
                {
                    _tr1tarPos = value;
                    if (_tr1tarPos < -4)
                    {
                        _tr1tarPos = -4;
                    }

                    if (_tr1tarPos > 0.1)
                    {
                        _tr1tarPos = 0.1;
                    }
                }
            }
            private double _tr2tarPos = -2;

            [DisplayName("TR2"), Description("运行目标位置，设定范围：-4~0.1，单位：mm")]
            public double TR2TarPos
            {
                get
                {
                    return _tr2tarPos;
                }
                set
                {
                    _tr2tarPos = value;
                    if (_tr2tarPos < -4)
                    {
                        _tr2tarPos = -4;
                    }

                    if (_tr2tarPos > 0.1)
                    {
                        _tr2tarPos = 0.1;
                    }
                }
            }
            public override string ToString()
            {
                return "...";
            }
        }
        public class Clamp_PushingForce
        {
            private short _tr1pushingForce = 40;

            [DisplayName("TR1"), Description("当夹持推力设定值不等于0，为推力运行; 若设定推力需大于等于推力阀值，设定范围：0-200,单位：%")]
            public short TR1PushingForce
            {
                get
                {
                    return _tr1pushingForce;
                }
                set
                {
                    _tr1pushingForce = value;
                    if (_tr1pushingForce < 0)
                    {
                        _tr1pushingForce = 0;
                    }

                    if (_tr1pushingForce > 200)
                    {
                        _tr1pushingForce = 200;
                    }
                    TR1pushingForce = _tr1pushingForce;
                }
            }
            private short _tr2pushingForce = 40;

            [DisplayName("TR2"), Description("当夹持推力设定值不等于0，为推力运行; 若设定推力需大于等于推力阀值，设定范围：0-200,单位：%")]
            public short TR2PushingForce
            {
                get
                {
                    return _tr2pushingForce;
                }
                set
                {
                    _tr2pushingForce = value;
                    if (_tr2pushingForce < 0)
                    {
                        _tr2pushingForce = 0;
                    }

                    if (_tr2pushingForce > 200)
                    {
                        _tr2pushingForce = 200;
                    }
                    TR2pushingForce = _tr2pushingForce;
                }
            }

            public override string ToString()
            {
                return "...";
            }
        }
        public class Clamp_PushingForceTriggerLV
        {
            private short _tr1triggerLV = 40;

            [DisplayName("TR1"), Description("推力阀值设定小于夹持推力，设定范围：0-200，单位：%")]
            public short TR1TriggerLV
            {
                get
                {
                    return _tr1triggerLV;
                }
                set
                {
                    _tr1triggerLV = value;
                    if (_tr1triggerLV < 0)
                    {
                        _tr1triggerLV = 0;
                    }
                    if (_tr1triggerLV > TR1pushingForce)
                    {
                        _tr1triggerLV = TR1pushingForce;
                    }
                }
            }

            private short _tr2triggerLV = 40;
            [DisplayName("TR2"), Description("推力阀值设定小于夹持推力，设定范围：0-200，单位：%")]
            public short TR2TriggerLV
            {
                get
                {
                    return _tr2triggerLV;
                }
                set
                {
                    _tr2triggerLV = value;
                    if (_tr2triggerLV < 0)
                    {
                        _tr2triggerLV = 0;
                    }
                    if (_tr2triggerLV > TR2pushingForce)
                    {
                        _tr2triggerLV = TR2pushingForce;
                    }
                }
            }
            public override string ToString()
            {
                return "...";
            }
        }

        public class Clamp_PushingForceInPos
        {
            private double _tr1inPos = 0.5;

            [DisplayName("TR1"), Description("推力范围+-，设定范围：0.1-4.0 单位:mm")]
            public double TR1InPos
            {
                get
                {
                    return _tr1inPos;
                }
                set
                {
                    _tr1inPos = value;

                    if (_tr1inPos < 0.1)
                    {
                        _tr1inPos = 0.1;
                    }

                    if (_tr1inPos > 4.0)
                    {
                        _tr1inPos = 4.0;
                    }
                }
            }
            private double _tr2inPos = 0.5;

            [DisplayName("TR2"), Description("推力范围+-，设定范围：0.1-4.0 单位:mm")]
            public double TR2InPos
            {
                get
                {
                    return _tr2inPos;
                }
                set
                {
                    _tr2inPos = value;

                    if (_tr2inPos < 0.1)
                    {
                        _tr2inPos = 0.1;
                    }

                    if (_tr2inPos > 4.0)
                    {
                        _tr2inPos = 4.0;
                    }
                }
            }
            public override string ToString()
            {
                return "...";
            }
        }
    }
}

